﻿using System.IO;

namespace IndirectX.Direct3D11
{
    public class DeviceContext
    {
        public InputAssembler InputAssembler;
        public OutputMerger OutputMerger;
        public Rasterizer Rasterizer;

        public VertexShader VertexShader;

        public PixelShader PixelShader;


        public DeviceContext()
        {
            this.InputAssembler = new InputAssembler();
            this.OutputMerger = new OutputMerger();
            this.Rasterizer = new Rasterizer();
        }

        public void ClearRenderTargetView(RenderTargetView renderTarget, Color4 color4)
        {
            //((Texture2D)renderTarget.Resource).Data = color

        }

        public void Draw(int vertexCount, int startVertexLocation)
        {
            // Input assembler stage
            var vertexBuffer = this.InputAssembler.VertexBuffers[0];
            
            // Vertex shader stage
            Process(vertexBuffer, VertexShader);

            // Rasterizer stage

            // Pixel shader stage

            // Output Merger stage
            //OutputMerger._renderTargets

        }

        private void Process(VertexBufferBinding vertexBuffer, VertexShader vertexShader)
        {
            vertexBuffer.Buffer.Data.Seek(vertexBuffer.Offset, SeekOrigin.Begin);

            var buffer = new byte[vertexBuffer.Stride];
            vertexBuffer.Buffer.Data.Read(buffer, 0, vertexBuffer.Stride);

            // Vertex Shader
        }


        public DataBox MapSubresource(Texture2D resource, int mipSlice, int arraySlice, MapMode mode, MapFlags flags)
        {
            return new DataBox(0, 0, null);
        }
    }



 
}